package com.ruoyi.web.controller.fan;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.control.domain.Mainventilator2History;
import com.ruoyi.control.service.IMainventilator2HistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 主通风机2号风机Controller
 *
 * @author ruoyi
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/control/mainventilatorTwoHistory")
public class Mainventilator2HistoryController extends BaseController
{
    @Autowired
    private IMainventilator2HistoryService mainventilator2HistoryService;

    /**
     * 查询主通风机2号风机列表
     */
    @PreAuthorize("@ss.hasPermi('control:mainventilatorTwoHistory:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mainventilator2History mainventilator2History)
    {
        startPage();
        List<Mainventilator2History> list = mainventilator2HistoryService.selectMainventilator2HistoryList(mainventilator2History);
        return getDataTable(list);
    }

    /**
     * 导出主通风机2号风机列表
     */
    @PreAuthorize("@ss.hasPermi('control:mainventilatorTwoHistory:export')")
    @Log(title = "主通风机2号风机", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Mainventilator2History mainventilator2History)
    {
        List<Mainventilator2History> list = mainventilator2HistoryService.selectMainventilator2HistoryList(mainventilator2History);
        ExcelUtil<Mainventilator2History> util = new ExcelUtil<Mainventilator2History>(Mainventilator2History.class);
        util.exportExcel(response, list, "主通风机2号风机数据");
    }

    /**
     * 获取主通风机2号风机详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:mainventilatorTwoHistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(mainventilator2HistoryService.selectMainventilator2HistoryById(id));
    }


    /**
     * 获取主通风机2号风机详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:mainventilatorTwoHistory:query')")
    @GetMapping(value = "/ByTagName/{tagName}")
    public AjaxResult ByTagName(@PathVariable("tagName") String tagName)
    {
        Integer[] arr=mainventilator2HistoryService.selectMainventilator2HistoryByTagName(tagName);
        System.out.println(arr);
        return success(arr);
    }
    /**
     * 新增主通风机2号风机
     */
    @PreAuthorize("@ss.hasPermi('control:mainventilatorTwoHistory:add')")
    @Log(title = "主通风机2号风机", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mainventilator2History mainventilator2History)
    {
        return toAjax(mainventilator2HistoryService.insertMainventilator2History(mainventilator2History));
    }

    /**
     * 修改主通风机2号风机
     */
    @PreAuthorize("@ss.hasPermi('control:mainventilatorTwoHistory:edit')")
    @Log(title = "主通风机2号风机", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mainventilator2History mainventilator2History)
    {
        return toAjax(mainventilator2HistoryService.updateMainventilator2History(mainventilator2History));
    }

    /**
     * 删除主通风机2号风机
     */
    @PreAuthorize("@ss.hasPermi('control:mainventilatorTwoHistory:remove')")
    @Log(title = "主通风机2号风机", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(mainventilator2HistoryService.deleteMainventilator2HistoryByIds(ids));
    }


    /**
     * 主通风机2故障次数  1天
     */
    @GetMapping("/getMainTwoTotal")
    public int getMainTwoTotal()
    {
        int total = mainventilator2HistoryService.getMainTwoTotal();
        return total;
    }
}
